/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package boundless.entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author hendrikdekock
 */
@Entity
@Table(name = "LEAGUE")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "League.findAll", query = "SELECT l FROM League l"),
    @NamedQuery(name = "League.findById", query = "SELECT l FROM League l WHERE l.id = :id"),
    @NamedQuery(name = "League.findByName", query = "SELECT l FROM League l WHERE l.name = :name")})
public class League implements Serializable {
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "league")
    private Collection<Invitebyid> invitebyidCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "league")
    private Collection<Gamehistory> gamehistoryCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "league1")
    private Collection<Invitebyemail> invitebyemailCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "leagueid")
    private Collection<Playerteam> playerteamCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "leagueid")
    private Collection<Fantasyteams> fantasyteamsCollection;
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "ID")
    private Integer id;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "NAME")
    private String name;
    @ManyToMany(mappedBy = "leagueCollection")
    private Collection<Account> accountCollection;
    @JoinColumn(name = "OWNERID", referencedColumnName = "ID")
    @ManyToOne(optional = false)
    private Account ownerid;

    public League() {
    }

    public League(Integer id) {
        this.id = id;
    }

    public League(Integer id, String name) {
        this.id = id;
        this.name = name;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @XmlTransient
    public Collection<Account> getAccountCollection() {
        return accountCollection;
    }

    public void setAccountCollection(Collection<Account> accountCollection) {
        this.accountCollection = accountCollection;
    }

    public Account getOwnerid() {
        return ownerid;
    }

    public void setOwnerid(Account ownerid) {
        this.ownerid = ownerid;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof League)) {
            return false;
        }
        League other = (League) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "boundless.entities.League[ id=" + id + " ]";
    }

    @XmlTransient
    public Collection<Fantasyteams> getFantasyteamsCollection() {
        return fantasyteamsCollection;
    }

    public void setFantasyteamsCollection(Collection<Fantasyteams> fantasyteamsCollection) {
        this.fantasyteamsCollection = fantasyteamsCollection;
    }

    @XmlTransient
    public Collection<Invitebyid> getInvitebyidCollection() {
        return invitebyidCollection;
    }

    public void setInvitebyidCollection(Collection<Invitebyid> invitebyidCollection) {
        this.invitebyidCollection = invitebyidCollection;
    }

    @XmlTransient
    public Collection<Gamehistory> getGamehistoryCollection() {
        return gamehistoryCollection;
    }

    public void setGamehistoryCollection(Collection<Gamehistory> gamehistoryCollection) {
        this.gamehistoryCollection = gamehistoryCollection;
    }

    @XmlTransient
    public Collection<Invitebyemail> getInvitebyemailCollection() {
        return invitebyemailCollection;
    }

    public void setInvitebyemailCollection(Collection<Invitebyemail> invitebyemailCollection) {
        this.invitebyemailCollection = invitebyemailCollection;
    }

    @XmlTransient
    public Collection<Playerteam> getPlayerteamCollection() {
        return playerteamCollection;
    }

    public void setPlayerteamCollection(Collection<Playerteam> playerteamCollection) {
        this.playerteamCollection = playerteamCollection;
    }
    
}
